<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="java.util.List" %> 
<%@ page import="java.util.ArrayList" %> 
<%@ page import="com.zust.java.bean.Account" %> 
<%@ page import="com.zust.java.bean.OrderView" %>
<%@ page import="java.text.SimpleDateFormat" %>          
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>生产者页面</title>
<script>
    function creatOrder() {
    	var check = confirm("确定创建订单?");
    	if (check == true) {
    		window.location.href='creatOrder';
    	}
    }
</script>
</head>
<body>
	<%
		List<OrderView> list = (List<OrderView>) request.getSession().getAttribute("orderView");/* new ArrayList<Order>(); */
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		Account account = (Account) request.getSession().getAttribute("account");
	%>
	<form action="searchOrderByJobShopName" ><!-- 依据承包人 -->
		<input name="username" type="text" >
		<input name="submit" type="submit" value="查询">
	</form>
	<br> <button name="creat" onclick="creatOrder()">创建订单</button>
	<br> <button name="drop" onclick="window.location.href='dropServlet'" >退出</button>
	<table border="1px">
	<tr>	
		<th>订单号</th>
		<th>创建时间</th>
		<th>最终期限</th>
		<th>承包人</th>
		<th>操作</th>
	</tr>
	<% for (OrderView o : list) {%>
	<tr>
		<td>	
			<%= o.getOrderNo() %>
		</td>
		<td><%= dateFormat.format(o.getCreatTime()) %></td>
		<td><%= dateFormat.format(o.getDeadline()) %></td>
		<% if (o.getUsername() != null && !o.getUsername().equals("0")) { %>
		<td>
			<a href="selectProcessor?username=<%= o.getUsername() %>&account=<%=account.getAccount()%>&type=<%=account.getType()%>">
				<%= o.getUsername() %>
			</a>
		</td>
		<% } else { %>
		<td>null</td>
		<% } %>
		<td>
			<input name="select" type="button" value="查看详情" onclick="window.location.href='selectOrderDetail?orderNo=<%= o.getOrderNo() %>&account1=<%= account.getAccount() %>&type=<%= account.getType() %>'">
		   <!--   <button name="reject" onclick="window.location.href='deleteJobShop?orderNo=<%= o.getOrderNo() %>&accountId=<%= account.getId()%>'">拒绝</button> -->
		</td>
	</tr>
	<% } %>
	</table>
</body>
</html>